package com.kingyea.app.market.utils;

import java.io.Serializable;
import java.util.List;

/**
 * @author cxc
 * @version v1.0.0
 * @description
 * @date Created in 2018.03.30 15:44
 */

public class BasePage<T> implements Serializable {

    /**
     * 是启用分页
     */
    public boolean isPageAble = true;
    /**
     * 页码，默认是第一页
     */
    private int pageNum = 1;
    /**
     * 每页显示的记录数，默认是10
     */
    private int pageSize = 10;
    /**
     * 总记录数
     */
    private int total;
    /**
     * 总页数
     */
    private int totalPage;
    /**
     * 对应的当前页记录
     */
    private List<T> list;

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
        //在设置总页数的时候计算出对应的总页数，在下面的三目运算中加法拥有更高的优先级，所以最后可以不加括号。
        int totalPage = total % pageSize == 0 ? total / pageSize : total / pageSize + 1;
        this.setTotalPage(totalPage);
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public boolean isPageAble() {
        return isPageAble;
    }

    public void setPageAble(boolean pageAble) {
        isPageAble = pageAble;
    }
}
